#include "types.h"
#include "q_perm.h"

#include <stdio.h>

int main(int argc, char** argv)
{
	int i,j;
	for(i = 0; i < 16; ++i)
	{
		for(j = 0; j < 16; ++j)
		{
			printf("%.2x ", q0_perm(i*16+j));
		}
		printf("\n");
	}
	if(argc != 3)
	{
		printf("Usage:program <0,1> <value>\n");
		return 1;
	}
	
	byte (*perm_func[2])(byte) = {
		q0_perm, q1_perm
	};

	int func_p;
	byte value;
	sscanf(argv[1], "%d", &func_p);
	sscanf(argv[2], "%x", &value);

	byte result = perm_func[func_p](value);

	printf("%.2x\n", result);

	return 0;
}
